home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / util / misc / keypress.rea < prev    next >
Text File  |  1995-09-03  |  3KB  |  60 lines

  1. Short:    Check if keys are pressed (for scripts)
  2. Author:   zodiac@darkness.gun.de (Ralph Seichter)
  3. Uploader: zodiac@darkness.gun.de
  4. Type:     util/batch
  5.  
  6.    This tool checks if at least one key of a given list of keys is pressed
  7. and delivers an appropriate return code, which can be processed in shell
  8. scripts to trigger any action you like.
  9.  
  10.    To give you an idea of what "KeyPressed" can do for you, imagine that
  11. you have three different startup-sequences around. Number 1 is the one for
  12. everyday use, the standard startup. Number 2 and 3 are optimized versions
  13. for special applications. When you want to execute number 2 or 3 on bootup,
  14. you could boot once without a startup-sequence, then copy the desired file
  15. over your standard startup (make sure to backup Number 1 first), and then
  16. reboot your Amiga. Does this sound inconvenient? It is.
  17.  
  18.    "KeyPressed" will help you out of your misery. Include the following
  19. lines somewhere at the beginning of your S:startup-sequence (your standard
  20. startup file) and copy "KeyPressed" to your C: directory or elsewehere in
  21. your command path.
  22.  
  23.         KeyPressed 64
  24.         IF WARN
  25.             ; KeyPressed reports that the space bar (raw key code 64)
  26.             ; was pressed. Execute alternate startup-sequence number 2.
  27.             Execute S:startup-sequence.2
  28.             EndCLI >NIL:
  29.             Quit
  30.         ENDIF
  31.  
  32.         KeyPressed 96 97 99
  33.         IF WARN
  34.             ; The control key (raw key code 99), the left shift key (96)
  35.             ; or the right shift key (97) was pressed. Execute alternate
  36.             ; startup-sequence number 3.
  37.             Execute S:startup-sequence.3
  38.             EndCLI >NIL:
  39.             Quit
  40.         ENDIF
  41.  
  42.    As you can see, "KeyPressed" requires a list of decimal raw key codes.
  43. You can supply as many codes as you wish, but as there is only a fixed
  44. number of keys on a keyboard, there is a natural limit implied. :)
  45.  
  46. "KeyPressed" will return the code 5 (RETURN_WARN) if at least one of the
  47. specified key was pressed, and otherwise 0 (RETURN_OK) is returned. Please
  48. Note that raw key codes are *DIFFERENT* from ASCII codes. Here is a list of
  49. selected codes common to all Amiga models:
  50.  
  51.         Key name                Code
  52.         Space bar               64
  53.         Enter (numeric keypad)  67
  54.         Return                  68
  55.         F1 - F10                80 - 89
  56.         Help                    95
  57.  
  58.    For a complete list of the Amiga's raw key codes, please have a look at
  59. the ROM Kernel Reference Manual "Devices" (section "console.device").
  60.